//
//  LiveVideoCoreSDK.h
//  LiveVideoCoreSDK
//
//  Created by gongdingxi on 16/3/2.
//  Copyright © 2016年 com.Alex. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>
#import <UIKit/UIKit.h>

#define kLiveVideoSize320P  (CGSizeMake(320, 568))
#define kLiveVideoSize480P  (CGSizeMake(480, 854))
#define kLiveVideoSize720P  (CGSizeMake(720, 1280))

extern NSString *const kLIVEVideoBitrateChangedNotification;

typedef NS_ENUM(NSUInteger, LIVEVideoBitrate) {
    kLIVEVideoBitrate1Mbps=1500000,
    kLIVEVideoBitrate800Kbps=800000,
    kLIVEVideoBitrate640Kbps=640000,
    kLIVEVideoBitrate500Kbps=500000,
    kLIVEVideoBitrate300Kbps=300000
};

typedef NS_ENUM(NSInteger, LIVESessionState)
{
    kLIVESessionStateNone,
    kLIVESessionStatePreviewStarted,
    kLIVESessionStateConnectFailed,
    kLIVESessionStateStarted,
    kLIVESessionStateDisconnect,
    kLIVESessionStateReconnected,
    kLIVESessionStatePoorNetwork,
    kLIVESessionStateEnded,
};

@protocol LIVESessionDelegate <NSObject>
@required
- (void) LiveConnectionStatusChanged: (LIVESessionState) sessionState;
@end

@interface LiveVideoCoreSDK : NSObject

@property(nonatomic, assign) BOOL          torch;    //是否开启闪光灯，默认=NO
@property(nonatomic, assign) BOOL          beautyFilter; //是否开启美颜，默认=YES
@property(nonatomic, assign) BOOL          useFrontCamera;  //是否使用前置摄像头，默认=YES
@property(nonatomic, copy)   NSString       *waterMark;

+ (instancetype)sharedinstance;

@property (nonatomic, weak)   id<LIVESessionDelegate> delegate;

- (instancetype)init __attribute__((unavailable("Must use sharedinstance instead.")));

/**
 **  次播调用该接口，可以设置码率／分辨率
 * initWith   : 初始化推流开始前的工作，并展示预览
 * @preview   : 推流时显示摄像头的预览uiview
 * @videoSize : 视频分辨率
 * @frameRate : 帧率
 * @bitrate   : 码率
 **/
- (void)initWithPreview:(UIView*)previewView VideoSize:(CGSize)videoSize BitRate:(int)bitrate;

/**
 **  主播调用该接口
 * initWith   : 初始化推流开始前的工作，并展示预览
 * @preview   : 推流时显示摄像头的预览uiview
 **/
- (void)initWithPreview:(UIView*)previewView;

/**
 * start      : 开始rtmp推流，一定要在initWith..后调用
 **/
- (void)startWithRtmpUrl:(NSString*)rtmpUrl ;
/**
 * stop       : 停止rtmp推流，每次调用start之后，如果要停止推流，一定要stop释放资源
 *
 **/
- (void)stop;

/**
 * reset      : 移除预览，释放相机等资源，一次直播的生命周期完整结束
 *
 **/
- (void)reset;

/**
 * 获取当前比特率
 **/
- (int)bitrate;

/**
 * 拍照，获取当前预览中的图片
 **/
- (UIImage*)capture;

/**
 *  setVideoZoomFactor
 *  以采集的图像中心为基准，对图像进行缩放,范围:1.0 - 6.0
 **/
- (void)setVideoZoomFactor:(CGFloat)videoZoomFactor;

/**
 *  setFocusPoint
 *  设置对焦点，(0,0)是左上角，(1,1)是右下角
 *  实际测试(0,0)是右上角，(1,1)是左下角
 **/
- (void)setFocusPoint:(CGPoint)focusPoint;

/**
 *  enableMic
 *  enable:是否打开麦克风
 *
 **/
- (void)enableMic:(BOOL)enable;

/**
 *  enableCamera
 *  enable:是否打开摄像头
 *
 **/
- (void)enableCamera:(BOOL)enable;
@end
